<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>走访记录管理</title>
<link href="/static/css/layout.css" rel="stylesheet" type="text/css" />
<link href="/static/css/cb.css" rel="stylesheet" type="text/css" />
<link href="/static/css/n.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css"
	href="/static/easyui/themes/default/easyui.css" />
<link rel="stylesheet" type="text/css" href="/static/easyui/themes/icon.css" />
<link rel="stylesheet" type="text/css" href="/static/easyui/demo/demo.css" />
<link rel="stylesheet" type="text/css"
	href="/static/js/laypage/skin/laypage.css" />
<script type="text/javascript" src="/static/easyui/jquery.min.js"></script>
<script src="/static/js/vue/vue.min.js" charset="utf-8"></script>
<script type="text/javascript" src="/static/easyui/jquery.easyui.min.js"></script>
<script type="text/javascript" src="/static/js/laypage/laypage.js"></script>
<script type="text/javascript" src="/static/laydate/laydate.js"></script>
</head>
<body>
	<div id="app">
		<table width="99%" border="0" align="center" cellpadding="0"
			cellspacing="0">
			<tr>
				<td width="1%" align="left" background="/static/images/b2.jpg"><img
					src="/static/images/b1.jpg" width="10" height="26" /></td>
				<td width="68%" background="/static/images/b2.jpg"><table
						width="124" border="0" align="left" cellpadding="0"
						cellspacing="0">
						<tr>
							<td width="20" align="left"><img src="/static/images/tz.gif"
								width="10" height="16" /></td>
							<td width="104" align="left" class="biao">查找走访信息</td>
						</tr>
					</table></td>
				<td width="31%" align="right" background="/static/images/b2.jpg"><img
					src="/static/images/b3.jpg" width="9" height="26" /></td>
			</tr>
		</table>

        <table width="99%" border="0" align="center" cellpadding="3"
               cellspacing="1" bgcolor="#AEDEF4">
            <tr>
                <td align="center" bgcolor="#E2F7FE">
                    <form id="form1" name="form1" method="post" action="">
                        <table width="90%" border="0" cellspacing="1" cellpadding="3">
                            <tr>
                                <td width="8%" align="right">矫正单位:</td>
                                <td width="8%" align="left">
                                    <select id="jid1" onchange="getMovePersonel()">
                                        <option value="0">任意</option>
                                        <option v-for="j in jnames" :value="j.id">{{j.name}}</option>
                                    </select>
                                </td>
                                <td width="8%" align="right">矫正人员:</td>
                                <td width="8%" align="left">
                                    <select id="cid1" style="width:120px; height: 17px" onchange="getWorkByCor()">
                                        <option value="0">任意</option>
                                        <option v-for="item in names" :value="item.id">{{item.name}}</option>
                                    </select>
                                </td>
                                <td width="8%" align="right">走访人员:</td>
                                <td width="8%" align="left">
                                    <select id="perid" style="width:120px; height: 17px">
                                        <option value="0">任意</option>
                                        <option v-for="w in works" :value="w.id">{{w.name}}</option>
                                    </select>
                                </td>
                                <td width="8%" align="right">迁居日期:</td>
                                <td width="8%" align="left"><input placeholder="请输入日期"
                                                                    class="laydate-icon" onclick="laydate()" id="startDate" /></td>
                                <td width="8%" align="left"><input placeholder="请输入日期"
                                                                    class="laydate-icon" onclick="laydate()" id="endDate" /></td>
                                <td width="8%" align="left"><input type="button"
                                                                    onclick="getPageList()" value="查找"/></td>
                                <td width="8%"  align="right">
                                    <input type="button" onclick="addEvent()" value="增加记录" />
                                    <input type="button" onclick="deleteBut()" value="批量删除" />
                                </td>
                                <td width="8%"  align="right">
                                    <input type="button" onclick="batch()" value="批量导出" />
                                    <input type="button" onclick="download()" value="全部导出"/>
                                </td>
                            </tr>
                        </table>
                    </form>
                </td>
            </tr>
        </table>
		<table width="50%" border="0" cellspacing="0" cellpadding="0">
			<tr>
				<td height="5"></td>
			</tr>
		</table>
		<table width="99%" border="0" align="center" cellpadding="0"
			cellspacing="0">
			<tr>
				<td width="1%" align="left" background="/static/images/b2.jpg"><img
					src="/static/images/b1.jpg" width="10" height="26" /></td>
				<td width="68%" background="/static/images/b2.jpg"><table
						width="124" border="0" align="left" cellpadding="0"
						cellspacing="0">
						<tr>
							<td width="20" align="left"><img src="/static/images/tz.gif"
								width="10" height="16" /></td>
							<td width="104" align="left" class="biao">走访记录列表</td>
						</tr>
					</table></td>
				<td width="31%" align="right" background="/static/images/b2.jpg"><img
					src="/static/images/b3.jpg" width="9" height="26" /></td>
			</tr>
		</table>
		<table width="99%" border="0" align="center" cellpadding="3"
		cellspacing="1" bgcolor="#AEDEF4" style="border: 1px solid #AEDEF4">
				<tr>
					<td align="center" bgcolor="#EFFBFE"><input type="checkbox" id="all"/></td>
					<td width="2%" height="25" align="center" bgcolor="#EFFBFE">序号</td>
					<td align="center" bgcolor="#EFFBFE">矫正单位</td>
					<td align="center" bgcolor="#EFFBFE">姓名</td>
					<td align="center" bgcolor="#EFFBFE">走访日期</td>
					<td align="center" bgcolor="#EFFBFE">走访人员</td>
					<td align="center" bgcolor="#EFFBFE">状态</td>
					<td align="center" bgcolor="#EFFBFE">管理操作</td>
				</tr>	
				<tr v-for="(item,index) in result"
							onmouseout="this.style.backgroundColor='#ffffff'"
							bgcolor="#ffffff" onmouseover="this.style.backgroundColor='#E6F2FF'">
							<td align="center"><input type="checkbox" name="id" :value="item.id" /></td>
							<td height="25" align="center"><span v-text="startIndex+index"></td>
							<td align="center">{{item.jname}}</td>
							<td align="center">{{item.cname}}</td>
							<td align="center">{{item.date}}</td>
							<td align="center">{{item.pname}}</td>
							<td align="center">{{item.state}}</td>
							<td align="left">
								<div align="left" style="padding-left: 5px">
									<div align="center">
										<input type="button" @click="checkEvent(item.id)" name="" value="查看" /> 
										<input type="button" @click="editEvent(item.id)" name="" value="修改" /> 
										<input type="button" @click="delEvent(item.id)" name="" value="删除" />
									</div>
								</div>
							</td>
			    </tr>
				<tr>
					<td colspan="6" align="center">
						<div id="pagediv"></div>
					</td>
				</tr>
		</table>
		<!-- 增加档案弹出框 -->
		<div id="dlg"></div>
		<!-- 查看档案弹出框 -->
		<div id="dlg1"></div>
		<!-- 修改期满登记弹出框 -->
		<div id="dlg2"></div>
	</div>

	<!-- js代码控制增删改查弹出层 -->
	<script>
		var app = new Vue({
			el : '#app',
			data : {
				names:[],
				jnames:[],
				works:[],
				result : [],
				startIndex:1
			}
			
		});
         /**
         * 查找司法所
         */
        var getJudicialDeptment = function () {
            $.ajax({
                url: "/judicialDeptment/queryAll",
                data: '',
                success: function (result) {
                    app.jnames = result.data;
                }
            });
        }
        /**
         * 根据司法所查找服刑人员
         */
        var getMovePersonel = function () {
            $.ajax({
                url: "/movePersonel/getAllCorrectedPerson",
                data: {
                    id: $('#jid1').val()
                },
                success: function (result) {
                    app.names = result.data;
                }
            });
        }
        /**
         * 根据服刑人员查找工作人员
		 */
		var getWorkByCor=function () {
            $.ajax({
                url: "/interview/getWorkByCor",
                data: {
                    pid: $('#cid1').val()
                },
                success: function (result) {
                    app.works = result.data;
                }
            });
        }
        getJudicialDeptment();
        /**
         * 导出Excel
		 */
		function download() {
			var url = "/interview/download";
			window.open(url);
		}
        /**
         * 模糊查询分页列表
		 * @param curr
         */
		var getPageList = function(curr) {
			$.ajax({
				type : "get",
				dataType : "json",
				url : "/interview/getlike",
				data : {
					pageNum : curr || 1,
					pageSize :10,
					jid : $("#jid1").val(),
					pid : $("#cid1").val(),
					perid : $("#perid").val(),
					startdate:$('#date').val(),
				    enddate:$('#date1').val()
				},
                /**
                 * 显示分页
				 * @param msg
                 */
				success : function(msg) {
					app.result = msg.data[0].result;
					app.startIndex=(msg.data[0].curPageNum-1)*msg.data[0].pageSize+1;
					laypage({
						cont : 'pagediv', //容器。值支持id名、原生dom对象，jquery对象,
						pages : msg.data[0].totalPage, //总页数
						first : "首页",
						last : "尾页",
						skip : true, //是否开启跳页
						skin : '#5675A2',
						curr : curr || 1, //当前页
						jump : function(obj, first) { //触发分页后的回调
							if (!first) { //点击跳页触发函数自身，并传递当前页：obj.curr
								getPageList(obj.curr);
							}
						}
					});
					invert(); 
				}
			});
		}
        /**
         * 获取档案记录列表
		 */
		getPageList();


        /**
         * 反选
		 */
		 var invert=function(){
			$("input[name='id']:checked").each(function(){
				if($(this).attr("checked",true)){
					$(this).removeAttr("checked");
				}
			})
		}
        /**
         * 增加档案记录
		 */
		var addEvent = function() {
			$('#dlg').dialog({
				title : '增加---档案',
				width : 720,
				height : 400,
				closed : false,
				cache : false,
				href : '/interview/getAllj',
				modal : true,
				buttons : [ {
					text : '保存',
					iconCls : 'icon-ok',
					handler : function() {
						$.ajax({
							url : "/interview/add",
							type : "post",
							contentType: false,  
					        processData: false, 
							async: false,  
					        cache: false,
							data : new FormData($("#form3")[0]),
							success : function(result) {
								$.messager.alert({
									title : '消息',
									msg : '保存成功!',
									icon : 'info'
								});
								getPageList();
								$('#dlg').dialog('close');
							}
						});
					}
				}, {
					text : '关闭',
					handler : function() {
						$('#dlg').dialog('close');
					}
				}]
			});
		}

        /**
         * 查看详情
		 * @param id
         */
		var checkEvent = function(id) {
			$('#dlg1').dialog({
				title : '查看---走访详情',
				width : 720,
				height : 400,
				closed : false,
				cache : false,
				href : '/interview/getId?id='+id,
				modal : true,
				buttons : [ {
					text : '关闭',
					handler : function() {
						$('#dlg1').dialog('close');
					}
				} ]
			});
		}
        /**
         * 修改期满登记事件
		 * @param id
         */
        var editEvent  = function(id) {
			$('#dlg2').dialog({
				title : '修改---走访登记 ',
				width : 600,
				height : 360,
				closed : false,
				cache : false,
				href : '/interview/getById?id=' + id,
				modal : true,
				buttons : [ {
					text : '保存',
					iconCls : 'icon-ok',
					handler : function() {
						var formDate = new FormData($('#form4')[0]);
						$.ajax({
							url : "/interview/edit",
							type : "post",
							dataType : "json",
							async : false,
							cache : false,
							contentType : false,
							processData : false,
							data : formDate,
							success : function(result) {
								if (result.code == 0) {
									$.messager.alert({
										title : '消息',
										msg : '修改成功!',
										icon : 'info'
									});
								};
								getPageList();
								$('#dlg2').dialog('close');
							}
						});
					}
				}, {
					text : '关闭',
					handler : function() {
						$('#dlg2').dialog('close');
					}
				} ]
			});
		}

        /**
         * 删除档案
		 * @param id
         */
		
		var delEvent = function(id){
		    $.messager.confirm('提示框', '你确定要删除吗?', function(res){
		    
		         if(res){
		              $.ajax({
		                  url : "/interview/del",
		                  type : "post",
		                  dateType : "json",
		                  data : {
		                      id : id 
		                  },
		                  success : function(result) {
		                      $.messager.alert({
		                          title : '消息',
								  msg : '删除成功!',
								  icon : 'info'
		                      });
		                      getPageList();
		                  }
		              });
		         }else{
		            //取消删除
		         }
		     
		    });
		}
        /**
		 * 批量删除走访信息
		 */
        var deleteBut = function () {
            var ids = [];
            $("input[name='id']:checked").each(function () {
                ids.push($(this).val());
            })
            if (ids.length == 0) {
                $.messager.alert({
                    title: '消息',
                    msg: '请选择要删除的信息!',
                    icon: 'info'
                });
            } else {
                $.messager.confirm('提示框', '你确定要删除吗?',
                        function (res) {
                            if (res) {
                                $.ajax({
                                    url: "/interview/deleteBatch",
                                    data: {
                                        ids: ids
                                    },
                                    success: function (result) {
                                        if (result.code == 0) {
                                            $.messager.alert({
                                                title: '消息',
                                                msg: '删除成功!',
                                                icon: 'info'
                                            });
                                            getPageList();
                                        }
                                    }
                                });
                            } else {
                                // 取消
                            }
                        })
            }
        }

        /**
         * 全选
		 */
		$(function(){
			$('#all').on('click',function(){
				var isChecked = $(this).prop("checked");
	            $("input[name='id']").prop("checked", isChecked);
			});
			   
	 	})
        /**
         * 批量导出
		 */
	 	var batch = function(){
	 	     var resid=[];
	 	     $("input[name='id']:checked").each(function(){//查找被选中的文本框值 并遍历
	 	            resid.push($(this).val());//加入resid集合
	 	     })
	 	     var url = "/interview/download?id="+resid;
			 window.open(url);
	 	}
	</script>



</body>
</html>